#include "cilib.h"

void* ciLoadBitmap(char* filename)
{
    FILE *fp;
    long filesize;
    void *ptr;


    if((fp=fopen(filename,"rb"))==NULL){
        return NULL;
    }

    fseek(fp,0L,SEEK_END);
    filesize=ftell(fp);
    fseek(fp,0L,SEEK_SET);

    printf("filesize=%d\n",filesize);
    ptr=(void* )malloc(filesize*sizeof(BYTE));

    fread(ptr,sizeof(BYTE),filesize,fp);


    fclose(fp);

    return ptr;

}

int ciGetFileSize(void* ptr)
{
    return ((BITMAPFILEHEADER*)ptr)->bfSize;
}
void ciSaveBitmap(void* ptr, char *filename)
{
    int filesize;
    FILE* fp;
    filesize=((BITMAPFILEHEADER*)ptr)->bfSize;
    if((fp=fopen(filename,"wb"))==NULL){
        return ;
    }

    fwrite(ptr,sizeof(BYTE),filesize,fp);

    fclose(fp);
}

